namespace CloundNinja.Metering.RowCountsProvider.Configuration
{
    using System.Configuration;

    using CloudNinja.Metering.Common.Configuration;
    using CloudNinja.Metering.Providers.Configuration;

    public class TenantRowCountConnectionCollectionElement : ConfigurationElement
    {
        [ConfigurationProperty("ServerAlias", IsRequired = true, DefaultValue = "")]
        public string ServerAlias
        {
            get
            {
                return (string)this["ServerAlias"];
            }

            set
            {
                this["ServerAlias"] = value;
            }
        }

        [ConfigurationProperty("ConnectionString", IsRequired = true, DefaultValue = "")]
        public string ConnectionString
        {
            get
            {
                var currentValue = (string)this["ConnectionString"];

                return this.GetCurrentValueOrDefault(currentValue);
            }

            set
            {
                this["ConnectionString"] = value;
            }
        }

        [ConfigurationProperty("TableName", IsRequired = false)]
        public string TableName
        {
            get
            {
                return (string)this["TableName"];
            }

            set
            {
                this["TableName"] = value;
            }
        }
        [ConfigurationProperty("TenantIdColumn", IsRequired = false)]
        public string TenantIdColumn
        {
            get
            {
                return (string)this["TenantIdColumn"];
            }

            set
            {
                this["TenantIdColumn"] = value;
            }
        }

        [ConfigurationProperty("CountColumn", IsRequired = false)]
        public string CountColumn
        {
            get
            {
                return (string)this["CountColumn"];
            }

            set
            {
                this["CountColumn"] = value;
            }
        }

        [ConfigurationProperty("TenantIdPattern", IsRequired = false)]
        public string TenantIdPattern
        {
            get
            {
                var currentValue = (string)this["TenantIdPattern"];

                return this.GetDefaultTenantIdPattern(currentValue);
            }

            set
            {
                this["TenantIdPattern"] = value;
            }
        }
    }
}